﻿using B.S.Business.ErrorCode;
using B.S.Business.Write.API.Applications.Command;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Business.Write.API.Controllers
{
    /// <summary>
    /// 采购管理 写-Api控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 采购添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<object>> PurchaseAdd(PurchaseAddCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 采购删除处理
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpDelete]
        public Task<ApiResult<object>> PurchaseDel([FromQuery]PurchaseDelCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut("PurchaseDels")]
        public async Task<ApiResult<string>> PurchaseDels([FromQuery]PurchaseDelsCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 采购更新处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public Task<ApiResult<object>> PurchaseUpd(PurchaseUpdCommand command)
        {
            return mediator.Send(command);
        }
    }
}
